package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domin.dto.QuestionFormDTO;
import com.tianji.learning.domin.dto.ReplyDTO;
import com.tianji.learning.domin.vo.QuestionVO;
import com.tianji.learning.query.QuestionPageQuery;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author author
 * @since 2023-09-08
 */
@Api(tags = "互动提问相关接口")
@RestController
@RequestMapping("/questions")
@RequiredArgsConstructor
public class InteractionQuestionController {

    private final IInteractionQuestionService questionService;

    @ApiOperation("添加问题")
    @PostMapping()
    public void addQuestions(@RequestBody @Validated QuestionFormDTO dto) {
        questionService.addQuestions(dto);
    }


    @ApiOperation("修改问题")
    @PutMapping("/{id}")
    public void updateQuestion(@PathVariable Long id, @RequestBody QuestionFormDTO dto) {
        questionService.updateQuestion(id, dto);

    }

    @ApiOperation("分页查询互动问题")
    @GetMapping("/page")
    public PageDTO<QuestionVO> queryQuestionPage(QuestionPageQuery query) {
        return questionService.queryQuestionPage(query);
    }

    @ApiOperation("根据id查询问题详情")
    @GetMapping("/{id}")
    public QuestionVO queryQuestionById(@ApiParam(value = "问题id", example = "1") @PathVariable("id") Long id) {
        return questionService.queryQuestionById(id);
    }

    @ApiOperation("根据id删除问题")
    @DeleteMapping("/{id}")
    public void deleteQuestionById(@ApiParam(value = "问题id", example = "1") @PathVariable("id") Long id) {
        questionService.deleteQuestionById(id);
    }



}
